<!-- 工作时长 -->

<template>
	<view>
		<view class="top-back">
			<view class="top-name">
				<view :class="topselect == 1?'top-selected':'top-select'" @click="clickPopSelect(1)">明细记录</view>
				<view :class="topselect == 2?'top-selected':'top-select'" @click="clickPopSelect(2)">时长统计
				</view>
			</view>

			<view class="top-right top-right-left" @click="exportAction">
				<view class="top-exit">导出</view>
			</view>

			<view v-if="topselect == 2" class="top-right" :class="sortSelect==''?'':'top-right-select'"
				@click="sortAction">
				<view v-if="sortSelect == ''" class="top-contnet">排序</view>
				<view v-if="sortSelect != ''" class="top-contnet top-content-select">{{sortSelect}}</view>
				<image v-if="sortSelect == ''" class="top-icon" src="../../../static/arrow_down.png"></image>
				<image v-if="sortSelect != ''" class="top-icon" src="../../../static/arrow_down_select.png"></image>
			</view>
			<view class="top-right" :class="screenSelect?'top-right-select':''" @click="selectAction">
				<view :class="screenSelect?'top-contnet top-content-select': 'top-contnet'">筛选</view>
				<image v-if="!screenSelect" class="top-icon" src="../../../static/select.png"></image>
				<image v-if="screenSelect" class="top-icon" src="../../../static/select_select.png"></image>
			</view>
		</view>
		<view class="uni-container" v-if="topselect == 1">
			<uni-table v-if="topselect == 1" ref="table" :loading="loading" stripe emptyText=" ">
				<uni-tr>
					<uni-th align="left" width="120">工作日期</uni-th>
					<uni-th align="left">工作内容</uni-th>
					<uni-th align="left" width="80">工作时长</uni-th>
					<uni-th align="left">工作律师</uni-th>
					<uni-th align="left">关联案件</uni-th>
					<uni-th align="left">登记人</uni-th>
					<uni-th align="left">登记时间</uni-th>
					<uni-th align="left">操作</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in tableData" :key="index">
					<uni-td align="left"><text selectable="true">{{ item.workDate }}</text></uni-td>
					<uni-td align="left"><text selectable="true">{{ item.workContent }}</text></uni-td>
					<uni-td align="left"><text selectable="true">{{ item.workDuration }}</text>
					</uni-td>
					<uni-td align="left"><text selectable="true" v-for="(value,ind) in item.lawyers"
							:key="ind">{{value.account.realName}}<text selectable="true"
								v-if="ind < item.lawyers.length - 1">,</text></text></uni-td>
					<uni-td align="left">
						<view class="item-blue-text" @click="clickShowAction(item)">查看</view>
					</uni-td>

					<uni-td align="left"><text selectable="true">{{ item.editAt?item.editAt:item.createAt }}</text>
					</uni-td>
					<uni-td align="left"><text
							selectable="true">{{ item.editTime?item.editTime:item.createTime  }}</text></uni-td>
					<uni-td align="left">
						<view style="display: flex;">
							<view class="item-blue-text" @click="delAction(item)">删除</view>
							<view style="margin-left: 12px;" class="item-blue-text" @click="editAction(item)">编辑</view>
						</view>
					</uni-td>
				</uni-tr>
			</uni-table>

			<view class="search-back" v-if="tableData.length == 0">
				<image class="search-image" :src="pc_search_nodata"></image>
				<view class="search-noresult">没有查询到结果</view>
			</view>
		</view>
		<view class="topselect-back" v-if="topselect == 2">
			<view @click="clickBtnSelect(1)" :class="topBtn==1?'top-btn-selected':'top-btn-select'">按律师统计</view>
			<view @click="clickBtnSelect(2)" :class="topBtn==2?'top-btn-selected':'top-btn-select'">按客户统计</view>
			<view @click="clickBtnSelect(3)" :class="topBtn==3?'top-btn-selected':'top-btn-select'">按案件统计</view>
		</view>
		<view class="uni-container" v-if="topselect == 2 && topBtn==1">
			<uni-table ref="table" :loading="loading" stripe emptyText=" ">
				<uni-tr>
					<uni-th align="left" >律师姓名</uni-th>
					<uni-th align="left" width="180">手机号</uni-th>
					<uni-th align="center" width="80">案件数</uni-th>
					<uni-th align="center" width="80">总时长</uni-th>

				</uni-tr>
				<uni-tr v-for="(item, index) in lwyerList" :key="index">
					<uni-td align="left"><text selectable="true">{{ item.lawyerName }}</text></uni-td>
					<uni-td align="left"><text selectable="true">{{ item.mobile }}</text></uni-td>
					<uni-td align="center"><text selectable="true">{{ item.caseNum }}</text>
					</uni-td>
					<uni-td align="center"><text selectable="true">{{ item.totalDuration }}</text>
					</uni-td>
				</uni-tr>
			</uni-table>

			<view class="search-back" v-if="tableData.length == 0">
				<image class="search-image" :src="pc_search_nodata"></image>
				<view class="search-noresult">没有查询到结果</view>
			</view>
		</view>
		<view class="uni-container" v-if="topselect == 2 && topBtn==2">
			<uni-table ref="table" :loading="loading" stripe emptyText=" ">
				<uni-tr>
					<uni-th align="left">客户名称</uni-th>
					<uni-th align="left" width="200">客户简称</uni-th>
					<uni-th align="center" width="80">案件数</uni-th>
					<uni-th align="center" width="80">总时长</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in custList" :key="index">
					<uni-td align="left">
						<view style="display: flex;">
							<image class="content-img" mode="aspectFill" src="../../../static/pc_customer.png"></image>
							<text selectable="true">{{ item.customerName }}</text>
						</view>
					</uni-td>
					<uni-td align="left"><text selectable="true">{{ item.customerShortName }}</text></uni-td>
					<uni-td align="center"><text selectable="true">{{ item.caseNum }}</text>
					</uni-td>
					<uni-td align="center"><text selectable="true">{{ item.totalDuration }}</text>
					</uni-td>
				</uni-tr>
			</uni-table>

			<view class="search-back" v-if="tableData.length == 0">
				<image class="search-image" :src="pc_search_nodata"></image>
				<view class="search-noresult">没有查询到结果</view>
			</view>
		</view>
		<view class="uni-container" v-if="topselect == 2 && topBtn==3">
			<uni-table ref="table" :loading="loading" stripe emptyText=" ">
				<uni-tr>
					<uni-th align="left" width="120">案件编号</uni-th>
					<uni-th align="left">主题词</uni-th>
					<uni-th align="left" width="120">咨询领域</uni-th>
					<uni-th align="center" width="80">案件状态</uni-th>
					<uni-th align="center" width="80">总时长</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in caseList" :key="index">
					<uni-td align="left">
						<view style="display: flex;">
							<image class="content-img" mode="aspectFill"
								src="../../../static/phone/phone_case_list_img.png"></image>
							{{ item.caseNo }}
						</view>
					</uni-td>
					<uni-td align="left"><text selectable="true">{{ item.subjectWords }}</text></uni-td>
					<uni-td align="left"><text selectable="true">{{ item.domain }}</text>
					</uni-td>
					<uni-td align="center"><text selectable="true">{{ item.caseStatus.desc }}</text>
					</uni-td>
					<uni-td align="center"><text selectable="true">{{ item.totalDuration }}</text>
					</uni-td>
				</uni-tr>
			</uni-table>

			<view class="search-back" v-if="tableData.length == 0">
				<image class="search-image" :src="pc_search_nodata"></image>
				<view class="search-noresult">没有查询到结果</view>
			</view>
		</view>
		<popSelect v-model="showSortSelect" :triangle=true :select="sortSelect" :popData="sortSelectdata"
			@tapPopup="tapPopup" :x="x" :y="y" placement="top-start" dynamic>
		</popSelect>
		<popSelect v-model="showScreen" :x="screenx" :y="screeny" placement="top-end" dynamic>
			<view v-if="showScreen && topselect == 1" class="screen-back">
				<uni-forms ref="baseForm" :modelValue="workFormData" style="width:200px;">
					<uni-forms-item>
						<uni-easyinput v-model="workFormData.accountQuery.realName" placeholder="工作律师" />
					</uni-forms-item>
					<uni-forms-item>
						<uni-easyinput v-model="workFormData.caseQuery.no" placeholder="案件编号" />
					</uni-forms-item>
					<uni-forms-item>
						<view style="display: flex;justify-content: space-between;">
							<view class="date-select-back" @click="openDatetimePicker(0)">
								<image class="dateimage" src="../../../static/pc_date.png"></image>
								<view v-if="workFormData.workstart" class="date-select-time">
									{{workFormData.workstart}}
								</view>
								<view v-else class="date-select-plac">工作日期起</view>
							</view>
							<view class="date-select-back" @click="openDatetimePicker(1)">
								<image class="dateimage" src="../../../static/pc_date.png"></image>
								<view v-if="workFormData.workend" class="date-select-time">
									{{workFormData.workend}}
								</view>
								<view v-else class="date-select-plac">工作日期止</view>
							</view>
						</view>
					</uni-forms-item>
					<view class="select-bottom">
						<view class="select-bottom-left" @click="selectReset">重置</view>
						<view class="select-bottom-right" @click="selectSureAction">筛选</view>
					</view>
				</uni-forms>
			</view>
			<!-- 律师 -->
			<view v-if="showScreen && topselect == 2 && topBtn==1" class="screen-back">
				<uni-forms ref="baseForm" :modelValue="lawyerFormData" style="width:200px;">
					<uni-forms-item>
						<uni-easyinput v-model="lawyerFormData.accountQuery.realName" placeholder="工作律师" />
					</uni-forms-item>
					<uni-forms-item>
						<uni-easyinput v-model="lawyerFormData.caseQuery.custName" placeholder="客户名称" />
					</uni-forms-item>
					<uni-forms-item>
						<uni-easyinput v-model="lawyerFormData.caseQuery.customerShortName" placeholder="客户简称" />
					</uni-forms-item>
					<uni-forms-item>
						<view style="display: flex;justify-content: space-between;">
							<view class="date-select-back" @click="openLawyerDatetimePicker(2)">
								<image class="dateimage" src="../../../static/pc_date.png"></image>
								<view v-if="lawyerFormData.workstart" class="date-select-time">
									{{lawyerFormData.workstart}}
								</view>
								<view v-else class="date-select-plac">工作日期起</view>
							</view>
							<view class="date-select-back" @click="openLawyerDatetimePicker(3)">
								<image class="dateimage" src="../../../static/pc_date.png"></image>
								<view v-if="lawyerFormData.workend" class="date-select-time">
									{{lawyerFormData.workend}}
								</view>
								<view v-else class="date-select-plac">工作日期止</view>
							</view>
						</view>
					</uni-forms-item>
					<view class="select-bottom">
						<view class="select-bottom-left" @click="selectReset">重置</view>
						<view class="select-bottom-right" @click="selectSureAction">筛选</view>
					</view>
				</uni-forms>
			</view>

			<!-- 客户 -->
			<view v-if="showScreen && topselect == 2 && topBtn==2" class="screen-back">
				<uni-forms ref="baseForm" :modelValue="custFormData" style="width:200px;">
					<uni-forms-item>
						<uni-easyinput v-model="custFormData.caseQuery.name" placeholder="客户名称" />
					</uni-forms-item>
					<uni-forms-item>
						<uni-easyinput v-model="custFormData.caseQuery.shortName" placeholder="客户简称" />
					</uni-forms-item>
					<uni-forms-item>
						<view style="display: flex;justify-content: space-between;">
							<view class="date-select-back" @click="openCustDatetimePicker(4)">
								<image class="dateimage" src="../../../static/pc_date.png"></image>
								<view v-if="custFormData.workstart" class="date-select-time">
									{{custFormData.workstart}}
								</view>
								<view v-else class="date-select-plac">工作日期起</view>
							</view>
							<view class="date-select-back" @click="openCustDatetimePicker(5)">
								<image class="dateimage" src="../../../static/pc_date.png"></image>
								<view v-if="custFormData.workend" class="date-select-time">
									{{custFormData.workend}}
								</view>
								<view v-else class="date-select-plac">工作日期止</view>
							</view>
						</view>
					</uni-forms-item>
					<view class="select-bottom">
						<view class="select-bottom-left" @click="selectReset">重置</view>
						<view class="select-bottom-right" @click="selectSureAction">筛选</view>
					</view>
				</uni-forms>
			</view>
			<!-- 案件 -->
			<view v-if="showScreen && topselect == 2 && topBtn==3" class="screen-back">
				<uni-forms ref="baseForm" :modelValue="caseFormData" style="width:200px;">
					<uni-forms-item>
						<uni-easyinput v-model="caseFormData.caseQuery.no" placeholder="案件编号" />
					</uni-forms-item>
					<uni-forms-item>
						<uni-easyinput v-model="caseFormData.customerQuery.name" placeholder="客户名称" />
					</uni-forms-item>
					<uni-forms-item>
						<uni-easyinput v-model="caseFormData.customerQuery.shortName" placeholder="客户简称" />
					</uni-forms-item>
					<uni-forms-item>
						<selectxy :zindex=299 ref="statusSelectxy" :value="statusMultipleArr" placeholder="案件状态"
							:options="statusRangeList" @change="statusMultipleChange">
						</selectxy>
					</uni-forms-item>
					<view class="select-bottom">
						<view class="select-bottom-left" @click="selectReset">重置</view>
						<view class="select-bottom-right" @click="selectSureAction">筛选</view>
					</view>
				</uni-forms>
			</view>
		</popSelect>
		<dateTimeSelect ref="myPicker" :type='date' @submit="handleSubmit" :start-year="2020" :end-year="2030" />
		<dateTimeSelect ref="lawyerPicker" :type='date' @submit="handleSubmit" :start-year="2020" :end-year="2030" />
		<dateTimeSelect ref="custPicker" :type='date' @submit="handleSubmit" :start-year="2020" :end-year="2030" />
		<uni-popup ref="alertDialog" type="dialog">
			<uni-popup-dialog type="danger" cancelText="取消" confirmText="确定" title="提示" content="确定要删除吗？"
				@confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
		</uni-popup>
		<addWorkTime v-if="showAddClass" :lawyerLists='lawyerList' :selectItem='selectItem' :editType='editType'
			v-on:successBack='updataRequest()' @addWorkTimeClose='clickWorkTimeClose'></addWorkTime>
	</view>
</template>

<script>
	import statusTag from "@/packageC/PhonePC/components/tags/tags.vue"
	import popSelect from '@/components/popSelect/popSelect.vue'
	import selectxy from "@/components/select-cy/select-cy.vue"
	import addWorkTime from "@/packageC/PhonePC/workTime/addWorkTime.vue"
	let app = ''

	export default {
		components: {
			statusTag,
			popSelect,
			selectxy,
			addWorkTime
		},
		data() {
			return {
				role: '', //当前登录角色
				roleUrl: '',
				topselect: 1,
				topBtn: 1,
				tableData: [],

				lwyerList: [],
				custList: [],
				caseList: [],
				showSortSelect: false,
				sortSelectdata: [{
					'title': '按总时长从高到低',
				}, {
					'title': '按总时长从低到高',
				}, ],
				sortSelect: "",
				x: 0,
				y: 0,

				sortSelect: "",
				screenx: 0,
				screeny: 0,
				showScreen: false,
				workFormData: {
					accountQuery: {
						realName: ''
					},
					caseQuery: {
						no: ''
					},
					workstart: "",
					workend: '',
				},
				screenSelect: false,
				dateSelectIndex: 0,
				lawyerFormData: {
					accountQuery: {
						realName: ''
					},
					caseQuery: {
						custName: '',
						customerShortName: ''
					},
					workstart: "",
					workend: '',
				},
				custFormData: {
					caseQuery: {
						name: '',
						shortName: ''
					},
					workstart: "",
					workend: '',
				},
				caseFormData: {
					caseQuery: {
						no: '',
						status: ''
					},
					customerQuery: {
						name: '',
						shortName: ''
					},
				},
				statusRangeList: [], //案件状态
				statusMultipleArr: [],
				statusSelectArr: [],
				selectItem: {},
				showAddClass: false,
				lawyerList: [],
				pc_search_nodata: getApp().globalData.baseImageUrl + '/pc_search_nodata.png',
				editType: ''
			}

		},
		mounted() {
			var _this = this;
			app = getApp()
			_this.role = app.globalData.role
			_this.roleUrl = _this.$roleUrl({
				tab: _this.role
			})
			this.requestData();
			this.requestLawyerData();
			this.requestCustData();
			this.requestCaseData();
			this.requestStatusDicData();
			this.requestLawyerList();
		},
		methods: {
			//网络请求示例
			async requestData() {

				let _this = this
				var url = `/${_this.roleUrl}/caseWorkLog/list`;
				let parmas = {
					size: '10000'
				};
				if (this.screenSelect && this.topselect == 1) {
					if (_this.workFormData.accountQuery.realName) {
						this.$set(parmas, 'accountQuery', _this.workFormData.accountQuery)
					}
					if (_this.workFormData.caseQuery.no) {
						this.$set(parmas, 'caseQuery', _this.workFormData.caseQuery)
					}

					if (_this.workFormData.workstart && !_this.workFormData.workend) {
						this.$set(parmas, 'workDate', 'ge:' + _this.workFormData.workstart)
					}
					if (!_this.workFormData.workstart && _this.workFormData.workend) {
						this.$set(parmas, 'workDate', 'le:' + _this.workFormData.workend)
					}
					if (_this.workFormData.workstart && _this.workFormData.workend) {
						this.$set(parmas, 'workDate', 'bt:' + _this.workFormData.workstart + ',' + _this
							.workFormData.workend)
					}
				}

				const res = await this.$myRequest({
					url: url,
					method: 'POST', //默认是GET
					data: parmas,
				})
				console.log('返回结果', res)
				if (res.data.code == 200) {
					var arr = [];
					for (var i = 0; i < res.data.data.list.length; i++) {
						var item = res.data.data.list[i]

						if (item.workDate) {
							var strs = item.workDate.split(' ');
							item.workDate = strs[0];
						}
						var lawyerArr = [];
						for (var j = 0; j < item.lawyers.length; j++) {
							var value = item.lawyers[j];
							if (value.status.code == '1') {
								lawyerArr.push(value)
							}
						}
						item.lawyers = lawyerArr;
						arr.push(item)
					}
					_this.tableData = arr;

				}
			},

			//律师
			async requestLawyerData() {

				let _this = this
				var url = `/${_this.roleUrl}/caseWorkLog/length/lawyer`;

				let parmas = {
					size: '1000'
				};
				if (_this.sortSelect == '按总时长从高到低') {
					this.$set(parmas, 'asc', 'totalDuration')
				}

				if (_this.sortSelect == '按总时长从低到高') {
					this.$set(parmas, 'desc', 'totalDuration')
				}

				if (this.screenSelect && this.topselect == 2 && this.topBtn == 1) {
					if (_this.lawyerFormData.accountQuery.realName) {
						this.$set(parmas, 'accountQuery', _this.lawyerFormData.accountQuery)
					}
					if (_this.lawyerFormData.caseQuery.custName || _this.lawyerFormData.caseQuery.customerShortName) {
						this.$set(parmas, 'caseQuery', _this.lawyerFormData.caseQuery)
					}
					if (_this.lawyerFormData.workstart && !_this.lawyerFormData.workend) {
						this.$set(parmas, 'workDate', 'ge:' + _this.lawyerFormData.workstart)
					}
					if (!_this.lawyerFormData.workstart && _this.lawyerFormData.workend) {
						this.$set(parmas, 'workDate', 'le:' + _this.lawyerFormData.workend)
					}
					if (_this.lawyerFormData.workstart && _this.lawyerFormData.workend) {
						this.$set(parmas, 'workDate', 'bt:' + _this.lawyerFormData.workstart + ',' + _this
							.lawyerFormData.workend)
					}
				}
				const res = await this.$myRequest({
					url: url,
					method: 'POST',
					data: parmas,
				})
				console.log('返回结果', res)
				if (res.data.code == 200) {
					_this.lwyerList = res.data.data
				}
			},

			//客户
			async requestCustData() {
				let _this = this
				var url = `/${_this.roleUrl}/caseWorkLog/length/cust`;

				let parmas = {
					size: '10000'
				};
				if (_this.sortSelect == '按总时长从高到低') {
					this.$set(parmas, 'asc', 'totalDuration')
				}

				if (_this.sortSelect == '按总时长从低到高') {
					this.$set(parmas, 'desc', 'totalDuration')
				}
				if (this.screenSelect && this.topselect == 2 && this.topBtn == 2) {
					if (_this.custFormData.caseQuery.name && !_this.custFormData.caseQuery.shortName) {
						this.$set(parmas, 'customerQuery', {
							'name': _this.custFormData.caseQuery.name
						})
					}
					if (!_this.custFormData.caseQuery.name && _this.custFormData.caseQuery.shortName) {
						this.$set(parmas, 'customerQuery', {
							'shortName': _this.custFormData.caseQuery.shortName
						})
					}
					if (_this.custFormData.caseQuery.name && _this.custFormData.caseQuery.shortName) {
						this.$set(parmas, 'customerQuery', _this.custFormData.caseQuery)
					}
					if (_this.custFormData.workstart && !_this.custFormData.workend) {
						this.$set(parmas, 'workDate', 'ge:' + _this.custFormData.workstart)
					}
					if (!_this.custFormData.workstart && _this.custFormData.workend) {
						this.$set(parmas, 'workDate', 'le:' + _this.custFormData.workend)
					}
					if (_this.custFormData.workstart && _this.custFormData.workend) {
						this.$set(parmas, 'workDate', 'bt:' + _this.custFormData.workstart + ',' + _this
							.custFormData.workend)
					}
				}
				const res = await this.$myRequest({
					url: url,
					method: 'POST', //默认是GET
					data: parmas,
				})
				console.log('返回结果', res)
				if (res.data.code == 200) {
					_this.custList = res.data.data
				}
			},

			//案件
			async requestCaseData() {
				let _this = this
				var url = `/${_this.roleUrl}/caseWorkLog/length/case`;

				let parmas = {
					size: '10000'
				};
				if (_this.sortSelect == '按总时长从高到低') {
					this.$set(parmas, 'asc', 'totalDuration')
				}
				if (_this.sortSelect == '按总时长从低到高') {
					this.$set(parmas, 'desc', 'totalDuration')
				}

				if (this.screenSelect && this.topselect == 2 && this.topBtn == 3) {
					//案件状态
					var dicStr = '';
					console.log(_this.statusSelectArr)
					if (_this.statusSelectArr.length) {
						for (var i = 0; i < _this.statusSelectArr.length; i++) {
							if (i == 0) {
								dicStr = _this.statusSelectArr[i].value
							} else {
								dicStr += "," + _this.statusSelectArr[i].value
							}
						}
						this.$set(_this.caseFormData.caseQuery, 'status', 'in:' + dicStr)
					}
					if (_this.caseFormData.caseQuery.no || dicStr) {
						this.$set(parmas, 'caseQuery', _this.caseFormData.caseQuery)
					}
					if (_this.caseFormData.customerQuery.name || _this.caseFormData
						.customerQuery.shortName) {
						this.$set(parmas, 'customerQuery', _this.caseFormData.customerQuery)
					}
				}

				const res = await this.$myRequest({
					url: url,
					method: 'POST', //默认是GET
					data: parmas,
				})
				console.log('返回结果', res)
				if (res.data.code == 200) {
					_this.caseList = res.data.data
				}
			},
			//导出
			exportAction() {

				let url = getApp().globalData.baseUrl + `/${_this.roleUrl}/caseWorkLog/export`;
				if (this.topselect == 2) {
					if (this.topBtn == 1) {
						url = getApp().globalData.baseUrl + `/${_this.roleUrl}/caseWorkLog/export/0`;
					}
					if (this.topBtn == 2) {
						url = getApp().globalData.baseUrl + `/${_this.roleUrl}/caseWorkLog/export/1`;
					}
					if (this.topBtn == 3) {
						url = getApp().globalData.baseUrl + `/${_this.roleUrl}/caseWorkLog/export/2`;
					}
				}
				uni.downloadFile({
					url: url,
					header: {
						"Content-Type": "application/x-xls",
						"Authorization": "Basic ZG90Z286ZG90Z28=",
						"token": uni.getStorageSync("accessToken") ? uni.getStorageSync("accessToken") : ''
					},
					success: function(res) {
						wx.hideLoading();
						wx.saveImageToPhotosAlbum({
							filePath: res.tempFilePath,
						}).then(save => {
							console.log('保存成功', save)
						}).catch(error => {
							console.log('保存失败', error)
						})
					},
					fail: function(err) {
						wx.hideLoading();
						console.log('下载失败：', err);
					},
				});
			},
			//案件状态
			async requestStatusDicData() {
				let _this = this
				const res = await this.$myRequest({
					url: "/comm/dict/list/$Status$cases",
					method: 'GET',
				})
				console.log('返回结果', res)
				if (res.data.code == 200) {
					var arr = [];
					for (var i = 0; i < res.data.data.length; i++) {
						var item = res.data.data[i]
						item.label = item.name;
						arr.push(item)
					}
					_this.statusRangeList = arr;
					console.log(_this.statusRangeList)
				}
			},

			//常用律师：网络请求
			async requestLawyerList() {
				let _this = this
				var url = "/admin/lawyer/selector";
				let parmas = {
					size: 1000,
					status: '1'
				};

				const res = await this.$myRequest({
					url: url,
					method: 'POST',
					data: parmas,
				})
				console.log('返回结果', res)
				if (res.data.code == 200) {
					_this.lawyerList = res.data.data;
				}
			},

			//案件状态
			statusMultipleChange(item, value) {
				this.statusSelectArr = item;
				this.statusMultipleArr = value;
			},
			async updataRequest() {
				this.requestData()
			},
			clickPopSelect(index) {
				this.topselect = index;
			},
			clickBtnSelect(index) {
				this.topBtn = index
			},
			clickShowAction(item) {
				this.$emit('clickTeamShow', item)
			},

			//排序
			sortAction(e) {
				this.x = e.touches[0].clientX
				this.y = e.touches[0].clientY
				this.showSortSelect = !this.showSortSelect
				console.log(this.x, this.y, this.value)
			},

			tapPopup(e) {
				console.log(e)
				this.sortSelect = e.title;
				this.requestLawyerData();
				this.requestCustData();
				this.requestCaseData();
			},
			// 日期选择打开picker
			openDatetimePicker(index) {
				this.dateSelectIndex = index;
				this.$refs.myPicker.show();
			},

			// 日期选择关闭picker
			closeDatetimePicker() {
				this.$refs.myPicker.hide();
			},
			// 律师日期选择打开picker
			openLawyerDatetimePicker(index) {
				this.dateSelectIndex = index;
				this.$refs.lawyerPicker.show();
			},
			openCustDatetimePicker(index) {
				this.dateSelectIndex = index;
				this.$refs.custPicker.show();
			},

			//日期选择
			handleSubmit(e) {
				// {year: "2019", month: "07", day: "17", hour: "15", minute: "21"}
				console.log(e);
				var time = `${e.year}-${e.month}-${e.day} `;
				if (this.dateSelectIndex == 0) {
					this.workFormData.workstart = time;
				} else if (this.dateSelectIndex == 1) {
					this.workFormData.workend = time;
				} else if (this.dateSelectIndex == 2) {
					this.lawyerFormData.workstart = time;
				} else if (this.dateSelectIndex == 3) {
					this.lawyerFormData.workend = time;
				} else if (this.dateSelectIndex == 4) {
					this.custFormData.workstart = time;
				} else if (this.dateSelectIndex == 5) {
					this.custFormData.workend = time;
				}

			},

			//筛选
			selectAction(e) {
				this.screenx = e.touches[0].clientX
				uni.getSystemInfo({
					success: res => {
						this.screenx = res.windowWidth - 30
					}
				})
				this.screeny = e.touches[0].clientY + 4
				this.showScreen = !this.showScreen
			},

			//筛选重置
			selectReset() {
				if (this.topselect == 1) {
					this.workFormData = {
							accountQuery: {
								realName: ''
							},
							caseQuery: {
								no: ''
							},
							workstart: "",
							workend: '',
						},
						this.requestData();
				}
				if (this.topselect == 2 && this.topBtn == 1) {
					this.lawyerFormData = {
							accountQuery: {
								realName: ''
							},
							caseQuery: {
								custName: '',
								customerShortName: ''
							},
							workstart: "",
							workend: '',
						},
						this.requestLawyerData();
				}
				if (this.topselect == 2 && this.topBtn == 2) {
					this.custFormData = {
							caseQuery: {
								name: '',
								shortName: ''
							},
							workstart: "",
							workend: '',
						},
						this.requestCustData();
				}

				if (this.topselect == 2 && this.topBtn == 3) {
					this.caseFormData = {
							caseQuery: {
								no: '',

							},
							customerQuery: {
								'name': '',
								'shortName': ''
							}
						},
						this.$refs.statusSelectxy.handleAllRemove();
					this.requestCaseData();
				}
				this.screenSelect = false;
			},
			//筛选确认	
			selectSureAction() {
				this.screenSelect = true;
				this.showScreen = !this.showScreen;
				if (this.topselect == 1) {
					this.requestData()
				}
				if (this.topselect == 2 && this.topBtn == 1) {
					this.requestLawyerData();
				}
				if (this.topselect == 2 && this.topBtn == 2) {
					this.requestCustData();
				}
				if (this.topselect == 2 && this.topBtn == 3) {
					this.requestCaseData();
				}
			},
			delAction(item) {
				this.selectItem = item;
				this.$refs.alertDialog.open()
			},
			async dialogConfirm() {
				console.log('点击确认')
				let _this = this

				let parmas = {
					'ids': this.selectItem.id,
				}
				const res = await this.$myRequest({
					url: "/admin/caseWorkLog",
					method: 'DELETE',
					data: parmas,
				})
				console.log('返回结果', res)
				if (res.data.code == 200) {
					_this.requestData()
				}
			},
			//编辑
			editAction(item) {
				this.editType = 'edit'
				this.selectItem = item
				this.showAddClass = true;
			},
			//关闭编辑
			clickWorkTimeClose() {
				this.showAddClass = false;
			},

			dialogClose() {
				console.log('点击关闭')
			},

		}
	}
</script>

<style scoped>
	.top-back {
		display: flex;
		align-items: center;
		padding: 10px;
	}

	.top-name {
		color: #333;
		font-size: 18px;
		font-weight: bold;
		margin-left: 30px;
		display: flex;
	}

	.top-num {
		color: #999;
		font-size: 18px;
		margin-left: 4px;
	}

	.top-contnet {
		font-size: 14px;
		color: #999;
	}

	.top-content-select {
		color: #2DA9C5;
	}

	.top-icon {
		width: 16px;
		height: 16px;
	}

	.top-right {
		cursor: pointer;
		display: flex;
		align-items: center;
		margin-right: 16px;
		margin-left: 16px;
		padding: 5px 10px;
		border-radius: 5px;
	}

	.top-right-left {
		margin-left: auto;
	}

	.uni-container {
		margin-left: 40px;
		margin-right: 16px;
		width: auto;
	}

	.search-back {
		width: 100%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
	}

	.search-noresult {
		font-size: 14px;
		color: #333;
		font-weight: 400;
	}

	.search-image {
		width: 150px;
		height: 150px;
	}

	.top-selected {
		cursor: pointer;
		font-size: 18px;
		font-weight: normal;
		color: #2DA9C5;
		border-bottom: #2DA9C5 1px solid;
		height: 35px;
		width: 75px;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-right: 40px;
	}

	.top-select {
		font-size: 18px;
		font-weight: normal;
		color: #333;
		cursor: pointer;
		height: 35px;
		width: 75px;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-right: 40px;
	}

	.top-exit {
		width: 56px;
		height: 30px;
		background: #E8F7FB;
		border-radius: 2px;
		font-size: 14px;
		font-weight: normal;
		color: #2DA9C5;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.item-blue-text {
		cursor: pointer;
		font-size: 14px;
		font-weight: 400;
		color: #2DA9C5;
	}

	.topselect-back {
		display: flex;
		margin-left: 40px;
		margin-top: 10px;
		margin-bottom: 10px;
	}

	.top-btn-selected {
		width: 76px;
		height: 24px;
		background: #E8F7FB;
		border-radius: 4px;
		font-size: 12px;
		font-weight: 400;
		color: #2DA9C5;
		margin-right: 10px;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.top-btn-select {
		width: 76px;
		height: 24px;
		background: #FFFFFF;
		border-radius: 4px;
		border: 1px solid #EEEEEE;
		font-size: 12px;
		font-weight: 400;
		color: #666666;
		margin-right: 10px;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.content-img {
		width: 24px;
		height: 24px;
		margin-right: 5px;
	}

	.top-right-select {
		background-color: #E8F7FB;
	}

	.select-bottom {
		display: flex;
	}

	.select-bottom-left {
		cursor: pointer;
		height: 32px;
		width: 120px;
		color: #333;
		background: #FFFFFF;
		border-radius: 2px;
		border: 1px solid #EEEEEE;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 14px;
	}

	.select-bottom-right {
		cursor: pointer;
		height: 32px;
		width: 120px;
		color: #fff;
		background: #8ED8E9;
		border-radius: 2px;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 14px;
		margin-right: 0px;
		margin-left: auto;
	}

	.screen-back {
		padding: 10px;
		width: 300px;
	}

	.date-select-back {
		width: 130px;
		height: 32px;
		background: #FFFFFF;
		border-radius: 2px;
		border: 1px solid #EEEEEE;
		display: flex;
		align-items: center;
	}

	.dateimage {
		width: 16px;
		height: 16px;
		margin-left: 10px;
		margin-right: 3px;
	}

	.date-select-plac {
		font-size: 12px;
		color: #999999;
	}

	.date-select-time {
		font-size: 12px;
		color: #333333;
	}
</style>
